import java.io.*;
import java.net.*;

public class FtpServer
{
	public static void main(String args[])
	{
		int port = 21214;
		if (args.length > 0)
			port = Integer.parseInt(args[0]);		
		System.out.println("FTP Server started");		System.out.println("Listening for connection...");
		try
		{
			ServerSocket sskt = new ServerSocket(port, 20);
			
			while (true)
			{
				Socket skt = sskt.accept();				System.out.println(skt.getInetAddress() + " connected");				
				new Thread(new ServerAgent(skt)).start();
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
